package com.xdap.common.controller;

import com.definesys.mpaas.common.http.Response;
import com.xdap.common.pojo.dto.CommonFixDataDto;
import com.xdap.common.service.CommonFixDataService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auth lishushu
 * @2024/3/18 9:24
 * @desc {公共功能中，默认自带的功能}
 **/
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/commonPlugin/defaultFeatures")
public class DefaultFeaturesController {


    @Autowired
    private CommonFixDataService commonFixDataService;

    /**
     * @auth lishushu
     * @2024/3/18 9:24
     * @desc {定时数据模型修复数据}
     **/
    @PostMapping("/fix/businessData")
    public Response fixData(@RequestBody CommonFixDataDto fixDataDto) {
        Response res = new Response();
        try {
            String result = commonFixDataService.fixData(fixDataDto);
            res.setData(result);
        } catch (Exception e) {
            log.error("修复数据时出现错误:{}", e);
            res.setMessage(e.getMessage());
            res.setCode(Response.CODE_ERR);

        }
        return res;
    }


}
